import 'package:bruno/bruno.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:sph_shipper/Main/WaybillInvoicing/InvoicingHistory.dart';
import 'package:sph_shipper/Main/WaybillInvoicing/ReceiptVoucher.dart';

import '../../AppConfig/Config.dart';
import '../../http/NoLoadingGetApi.dart';
import '../../l10n/messages.dart';

class WaybillInvoicing extends StatefulWidget {
  const WaybillInvoicing({super.key});

  @override
  State<WaybillInvoicing> createState() => _WaybillInvoicingState();
}

class _WaybillInvoicingState extends State<WaybillInvoicing> {
  int authType=1;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getUserInfo();
  }
  void getUserInfo(){
    NoLoadinggetApiManager.getData(
      context, // 上下文对象，用于显示提示信息等
      'api/auth/shipper/user/getLoginUser', // 您的API端点
      {}, // 查询参数，如果没有可以传递null
          (responseData)  {
        setState(() {

        });
      },
    );
  }
  @override
  Widget build(BuildContext context) {
    var messages = AppLocalizations.of(context)!;
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
      appBar: AppBar(
        leading: IconButton(icon: Icon(Icons.arrow_back_ios,color: Colors.black,),onPressed: (){Navigator.pop(context);},),
        backgroundColor: Colors.white,
        centerTitle: true,
        title: Text(messages["运单开票"],style: TextStyle(color: Colors.black,fontWeight: FontWeight.w300,fontSize: 16.sp),),
      ),
      body:ListView(
        children: [
          Container(
            margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),
            padding: EdgeInsets.only(left: 8.w,right: 8.w,top: 10.h,bottom: 10.h),
          decoration: BoxDecoration(
              color: Colors.white,
            borderRadius: BorderRadius.all(Radius.circular(10),),
          ),
            child: Column(
              children: [
                authType==0?
                Row(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  children: [
                    SizedBox(width: 8.w,),
                    Text("企业信息",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w600,fontSize: 14.sp),),
                    SizedBox(width: 4.w,),
                    Text("认证企业用户，找车快，有保障",style: TextStyle(color: MyColors.textColor,fontSize:MyFontSizes.smallText.sp ),),
                  ],
                ):
                Row(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Row(
                      children: [
                        SizedBox(width: 8.w,),
                        Text("企业信息",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w600,fontSize: 14.sp),),
                      ],
                    ),
                    GestureDetector(
                      child:   Row(
                        children: [
                          Image.asset("lib/Images/PersonCenter/运单开票修改icon.png",width: 16.w,height: 16.h,),
                          Text("修改",style: TextStyle(color: MyColors.themeColor,fontSize: 14.sp),),
                        ],
                      ),
                      onTap: (){

                      },
                    ),

                  ],
                ),
                SizedBox(height: 10.h,),
                Container(
                  height: 1.h,
                  color: MyColors.backgreyColor,
                ),
                SizedBox(height: 10.h,),
                authType==0?
                GestureDetector(
                  child:Container(
                    width: 120.w,
                    height: 30.h,
                    decoration: BoxDecoration(
                      color: MyColors.themeColor,
                      borderRadius: BorderRadius.all(  Radius.circular(30),),
                    ),
                    child: Center(
                      child: Text("前往企业认证",style: TextStyle(color: Colors.white, fontSize: 14.sp,fontWeight: FontWeight.w600),),
                    ),
                  ),
                  onTap: (){

                  },
                ):
                    Column(
                      children: [
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text("  "+"名称：",style: TextStyle(color: Colors.black,fontSize: 13.sp),),
                            Text("XXXX股份有限公司",style: TextStyle(color: Colors.black,fontSize: 13.sp),),
                          ],
                        ),
                        SizedBox(height: 10.h,),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text("  "+"发票抬头：",style: TextStyle(color: Colors.black,fontSize: 13.sp),),
                            Text("XXXX股份有限公司",style: TextStyle(color: Colors.black,fontSize: 13.sp),),
                          ],
                        ),
                        authType==1?
                        GestureDetector(
                          child:
                          Container(
                            width: 120.w,
                            height: 30.h,
                            margin: EdgeInsets.only(top: 10.h),
                            decoration: BoxDecoration(
                              color: MyColors.themeColor,
                              borderRadius: BorderRadius.all(  Radius.circular(30),),
                            ),
                            child: Center(
                              child: Text("开通发票服务",style: TextStyle(color: Colors.white, fontSize: 14.sp,fontWeight: FontWeight.w600),),
                            ),
                          ),
                          onTap: (){

                          },
                        ):SizedBox(height: 0,),
                      ],
                    ),
                
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 8.h),
            padding: EdgeInsets.only(left: 8.w,right: 8.w,top: 10.h,bottom: 10.h),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(10),),
            ),
            child: Column(
              children: [
                Row(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  children: [
                    SizedBox(width: 8.w,),
                    Text(messages["运单开票"],style: TextStyle(color: Colors.black,fontWeight: FontWeight.w600,fontSize: 14.sp),),

                  ],
                ),
                SizedBox(height: 10.h,),
                Container(
                  height: 1.h,
                  color: MyColors.backgreyColor,
                ),
                SizedBox(height: 10.h,),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [

                    BrnIconButton(
                        name: messages["专票"],
                        style: TextStyle(
                          fontSize: 13.sp,
                          color: Colors.black,
                        ),
                        direction: Direction.bottom,
                        padding: 4.h,
                        iconHeight: 26.h,
                        iconWidth: 26.w,
                        iconWidget: Image.asset("lib/Images/PersonCenter/专票icon.png"),
                        onTap: () {
                          Navigator.push(context,
                              MaterialPageRoute(builder: (context) {
                                return InvoicingHistory();
                              }));
                        }),
                    BrnIconButton(
                        name: messages["普票"],
                        style: TextStyle(
                          fontSize: 13.sp,
                          color: Colors.black,
                        ),
                        direction: Direction.bottom,
                        padding: 4.h,
                        iconHeight: 26.h,
                        iconWidth: 26.w,
                        iconWidget: Image.asset("lib/Images/PersonCenter/普票icon.png"),
                        onTap: () {
                          BrnToast.show('该功能未开启，敬请期待', context);
                        }),
                    BrnIconButton(
                        name: messages["收款凭证"],
                        style: TextStyle(
                          fontSize: 13.sp,
                          color: Colors.black,
                        ),
                        direction: Direction.bottom,
                        padding: 4.h,
                        iconHeight: 26.h,
                        iconWidth: 26.w,
                        iconWidget: Image.asset("lib/Images/PersonCenter/收款凭证icon.png"),
                        onTap: () {
                          Navigator.push(context,
                              MaterialPageRoute(builder: (context) {
                                return ReceiptVoucher();
                              }));
                        }),

                  ],
                )
              ],

            ),
          ),
        ],
      ),
    );
  }
}
